home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
PCACHSRC.ZIP
/
MEMBER.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-09-11
|
2KB
|
59 lines
;MEMBER.ASM
;links with OOP.CPP. Was created by firstly compiling to .ASM o/p
;with a stub in place, to obtain this skeleton.....
; BCC -c -S OOP.CPP
;-c suppresses linking, -S generates .ASM output.
;Note that i have heavily optimised this and it looks nothing like the
;original skeleton. By use of EXTRN's i have used the labels from the
;C++ module... note also the mangled names for the external functions.
PUBLIC @circle@place$qii
EXTRN @box@place$qii:NEAR
EXTRN @circle@draw$qv:WORD ;NEAR
EXTRN _box1:NEAR
;note that I can't reference C++ member-data by name (eg;_col).
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME cs:_TEXT
@circle@place$qii PROC NEAR
push bp
mov bp,sp
push si
mov si,[bp+4] ;addr of current object (this).
mov ax,[bp+6] ;parameter r, passed on stack.
mov [si]+0,ax ;accessing data of current object.
mov ax,[bp+8] ;parameter c
mov [si]+2,ax ;ditto. (copying c to col).
;to access another function, belonging to another object....
;box1.place(1,2)....
mov ax,2 ;put params on stack.
push ax
mov ax,1
push ax
mov ax,OFFSET _box1
push ax ;pass addr of box1 to C++ function.
call @box@place$qii
add sp,6 ;remove params from stack.
;to access another function, current object....
;this->draw()....
push si ;addr this object (no other params to pass).
mov bx,@circle@draw$qv
call [si+bx]
add sp,2 ;remove param from stack.
pop si
pop bp
ret
@circle@place$qii ENDP
_TEXT ENDS
END
;note that in theory we could access the data-members of any object,
;regardless of whether they're private or public. You can see above
;how we got the address of _box1 into SI.... a simple indexed move
;can access any of _box1's fields.